import request from "@/utils/request";
import {BaseResponse} from "@/api/types/baseResponse";
import OrderResponse from "@/api/types/order/OrderResponse";
import {OrderStatus} from "@/api/types/order/OrderStatus";

// 根据日期查询所有订单
export async function getOrdersByDate(date: string) {
    return await request<BaseResponse<OrderResponse[]>, BaseResponse<OrderResponse[]>>({
        url: "/meal/weborder",
        method: "GET",
        params: {orderdate: date}
    })
}

// 根据日期和状态查询所有订单
export async function getOrdersByDateAndStatus(date: string, status: OrderStatus) {
    return await request<BaseResponse<OrderResponse[]>, BaseResponse<OrderResponse[]>>({
        url: "/meal/weborder",
        method: "GET",
        params: {orderdate: date, orderstatus: status}
    })
}

// 将订单更改为已送达
export async function updateOrderStatusToDelivered(orderIds: string[]) {
    return await request<BaseResponse<{}>, BaseResponse<{}>>({
        url: "/meal/webupdatestatus",
        method: "PUT",
        data: {orderid_list: orderIds}
    })
}
